/**
 * 
 */
package at.ac.tuwien.ifs.qse.se1.services;

import java.util.List;
import at.ac.tuwien.ifs.qse.se1.bo.Student;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

/**
 * A XML exporter, which exports the given data to XML-Files.
 * <p>
 * The XML exporter uses XStream, an open source Serializer from Codehaus. XStream is a simple
 * library to serialize objects to XML and back again.
 * @author Demolsky Markus
 */
public class XMLExporter implements IExporter {
    // Declarations
    private XStream xstream = new XStream(new DomDriver());

    /*
     * (non-Javadoc)
     * @see at.ac.tuwien.ifs.qse.se1.services.IExporter#exportStudents(java.util.List)
     */
    public void exportStudents(List<Student> students) throws Exception {
        // Set alias names for XML file
        xstream.alias("students", List.class); // All students are enclosed in a <students> tag
        xstream.alias("student", Student.class); // Every Student is enclosed in a <student> tag
        System.out.println(xstream.toXML(students));
    }
}
